package cn.fintecher.gis.respository;

import cn.fintecher.gis.entity.RestsInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface RestsInfoRepository extends QuerydslPredicateExecutor<RestsInfo>, JpaRepository<RestsInfo, String> {

    @Query(value = "select sum(acreage) as area,to_char(create_time,'yyyy') as applyTime,unit from rests_info where id in(:ids) GROUP BY applyTime,unit", nativeQuery = true)
    public Object[] getStaticalRestsByYear(@Param("ids") List<String> ids);
}
